<template>
  <div class="app-container">
    <RoomTree v-model="currentTree" @change="treeClick" />
    <div class="container_body">
      <el-form
        :model="queryParams"
        ref="queryForm"
        size="small"
        :inline="true"
        v-show="showSearch"
        label-width="68px"
      >
        <!-- <el-form-item label="学校名称" prop="sId">
            <FusionSelect type="school" v-model="queryParams.sId" />
          </el-form-item>
          <el-form-item label="校区名称" prop="aId">
            <FusionSelect type="area" :instantly="false" paramsKey="pid" :paramsVal="queryParams.sId" v-model="queryParams.aId" />
          </el-form-item>
          <el-form-item label="楼座名称" prop="pId">
            <FusionSelect type="build" :instantly="false" paramsKey="pid2" :paramsVal="queryParams.aId" v-model="queryParams.pId" />
          </el-form-item>
          <el-form-item label="所属楼层" prop="floor">
            <FusionSelect type="floor" :instantly="false" paramsKey="build" :paramsVal="queryParams.pId" v-model="queryParams.floor" />
        </el-form-item>-->
        <!-- <el-form-item label="房间号码" prop="roomNo">
            <el-input v-model="queryParams.roomNo" placeholder="请输入房间号码" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>-->
        <el-form-item label="房间号码" prop="id">
          <RoomSelect v-model="queryParams.id" :params="roomSelectParams" />
        </el-form-item>
        <!-- <el-form-item label="串口服务器" prop="deviceName" label-width="100px">
          <el-input
            v-model="queryParams.deviceName"
            placeholder="请输入串口服务器"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>-->
        <el-form-item label="设备编号" prop="meterNo">
          <el-input
            v-model="queryParams.meterNo"
            placeholder="请输入设备编号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查询</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>

      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button
            type="primary"
            icon="el-icon-plus"
            size="mini"
            @click="handleAdd"
            v-hasPermi="['base:room:add']"
          >新增</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="success"
            icon="el-icon-edit"
            size="mini"
            :disabled="single"
            @click="handleUpdate"
            v-hasPermi="['base:room:edit']"
          >编辑</el-button>
        </el-col>
        <el-col :span="1.8">
          <el-button v-hasPermi="['base:room:edit']" type="success" icon="el-icon-edit" :disabled="multiple" size="mini" @click="updateOpen = true">批量编辑</el-button>
        </el-col>
        <el-col :span="1.8">
          <el-button v-hasPermi="['base:room:batch:price']" type="primary" icon="el-icon-edit" :disabled="multiple" size="mini" @click="priceOpen = true">单价设置</el-button>
        </el-col>
        <el-col :span="1.8">
          <el-button v-hasPermi="['base:room:device:set']" type="primary" icon="el-icon-edit" :disabled="single" size="mini" @click="handleDevice">更换设备</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="danger"
            icon="el-icon-delete"
            size="mini"
            :disabled="multiple"
            @click="handleDelete"
            v-hasPermi="['base:room:remove']"
          >删除</el-button>
        </el-col>
        <!-- <el-col :span="1.5">
          <el-button type="info" icon="el-icon-upload2" size="mini">导入</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="warning"
            icon="el-icon-download"
            size="mini"
            @click="handleExport"
            v-hasPermi="['base:room:export']"
          >导出</el-button>
        </el-col> -->
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
      </el-row>

      <el-table v-loading="loading" :data="roomList" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="房间号码" align="center" prop="roomNo" />
        <el-table-column label="是否有效" align="center" prop="enabled">
          <template slot-scope="scope">{{ scope.row.enabled == 1 ? '有效' : '无效' }}</template>
        </el-table-column>
        <el-table-column label="串口服务器" align="center" prop="deviceName" />
        <el-table-column label="设备编号" align="center" prop="meterNo" />
        <el-table-column label="所属楼层" align="center" prop="floorNo" />
        <el-table-column label="楼座名称" align="center" prop="buildName" />
        <el-table-column label="校区名称" align="center" prop="schoolAreaName" />
        <el-table-column label="学校名称" align="center" prop="schoolName" />
        <el-table-column
          label="操作"
          align="center"
          class-name="small-padding fixed-width"
          width="130"
        >
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="success"
              icon="el-icon-edit"
              @click="handleUpdate(scope.row)"
              v-hasPermi="['base:room:edit']"
            >修改</el-button>
            <el-button
              size="mini"
              type="danger"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)"
              v-hasPermi="['base:room:remove']"
            >删除</el-button>
          </template>
        </el-table-column>
      </el-table>

      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>

    <!-- 添加或修改房间档案对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-row>
        <el-form ref="form" :model="form" :rules="rules" label-width="120px">
          <el-col :span="12">
            <el-form-item label="学校名称" prop="sId">
              <FusionSelect type="school" v-model="form.sId" style="width: 100%;" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="校区名称" prop="aId">
              <FusionSelect
                type="area"
                :instantly="false"
                paramsKey="pid"
                :paramsVal="form.sId"
                v-model="form.aId"
                style="width: 100%;"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="楼座名称" prop="pId">
              <FusionSelect
                type="build"
                :instantly="false"
                paramsKey="pid2"
                :paramsVal="form.aId"
                v-model="form.pId"
                style="width: 100%;"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="所属楼层" prop="floor">
              <FusionSelect
                type="floor"
                :instantly="false"
                paramsKey="buildId"
                :paramsVal="form.pId"
                v-model="form.floor"
                style="width: 100%;"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="房间号码" prop="roomNo">
              <el-input v-model="form.roomNo" placeholder="请输入房间号码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否有效" prop="enabled">
              <el-select v-model="form.enabled" placeholder="请选择是否有效" style="width: 100%;">
                <el-option label="全部" value=""></el-option>
                <el-option label="有效" :value="1" />
                <el-option label="无效" :value="0" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="串口服务器" prop="cjqId">
              <el-select v-model="form.cjqId" placeholder="请选择串口服务器" style="width: 100%;">
                <el-option label="全部" value=""></el-option>
                <el-option
                  v-for="item in deviceOption"
                  :key="item.id"
                  :label="item.cjqNo"
                  :value="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设备编号" prop="meterNo">
              <el-input v-model="form.meterNo" placeholder="请输入设备编号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设备协议" prop="PTTC">
              <el-select v-model="form.PTTC" placeholder="请选择" style="width: 100%;">
                <el-option label="全部" value=""></el-option>
                <el-option label="PTTC" value="PTTC" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="联系人" prop="linkMan">
              <el-input v-model="form.linkMan" placeholder="请输入联系人" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="联系电话" prop="tel">
              <el-input v-model="form.tel" placeholder="请输入联系电话" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="报警电量" prop="alarmEq">
              <el-input v-model="form.alarmEq" placeholder="请输入报警电量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="最大透支" prop="maxTzEq">
              <el-input v-model="form.maxTzEq" placeholder="请输入最大透支" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="最大围积" prop="maxTjEq">
              <el-input v-model="form.maxTjEq" placeholder="请输入最大围积" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="最大一次售电" prop="maxBuyEq">
              <el-input v-model="form.maxBuyEq" placeholder="请输入最大一次售电" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="补助电量" prop="freeEq">
              <el-input v-model="form.freeEq" placeholder="请输入补助电量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="售电单价" prop="eqPrice">
              <el-input v-model="form.eqPrice" placeholder="请输入售电单价" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="结转方式" prop="jzType">
              <el-select v-model="form.jzType" placeholder="请选择" style="width: 100%;">
                <el-option label="自动结转" :value="1" />
                <el-option label="人工结转" :value="2" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="补助结转下月" prop="isJzFreeEq">
              <el-select v-model="form.isJzFreeEq" placeholder="请选择" style="width: 100%;">
                <el-option label="是" :value="1" />
                <el-option label="否" :value="0" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 批量编辑弹窗 -->
    <el-dialog :title="title" :visible.sync="updateOpen" width="800px" append-to-body>
      <el-row>
        <el-form ref="form" :model="form" :rules="rules" label-width="120px">
          <el-col :span="12">
            <el-form-item label="串口服务器" prop="cjqId">
              <el-select v-model="form.cjqId" placeholder="请选择串口服务器" style="width: 100%;">
                <el-option
                  v-for="item in deviceOption"
                  :key="item.id"
                  :label="item.cjqNo"
                  :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设备协议" prop="PTTC">
              <el-select v-model="form.PTTC" placeholder="请选择" style="width: 100%;">
                <el-option label="PTTC" value="PTTC" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否有效" prop="enabled">
              <el-select v-model="form.enabled" placeholder="请选择是否有效" style="width: 100%;">
                <el-option label="有效" :value="1" />
                <el-option label="无效" :value="0" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="报警电量" prop="alarmEq">
              <el-input v-model="form.alarmEq" placeholder="请输入报警电量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="最大透支" prop="maxTzEq">
              <el-input v-model="form.maxTzEq" placeholder="请输入最大透支" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="最大围积" prop="maxTjEq">
              <el-input v-model="form.maxTjEq" placeholder="请输入最大围积" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="最大一次售电" prop="maxBuyEq">
              <el-input v-model="form.maxBuyEq" placeholder="请输入最大一次售电" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="补助电量" prop="freeEq">
              <el-input v-model="form.freeEq" placeholder="请输入补助电量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="售电单价" prop="eqPrice">
              <el-input v-model="form.eqPrice" type="number" placeholder="请输入售电单价" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="结转方式" prop="jzType">
              <el-select v-model="form.jzType" placeholder="请选择" style="width: 100%;">
                <el-option label="自动结转" :value="1" />
                <el-option label="人工结转" :value="2" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="补助结转下月" prop="isJzFreeEq">
              <el-select v-model="form.isJzFreeEq" placeholder="请选择" style="width: 100%;">
                <el-option label="是" :value="1" />
                <el-option label="否" :value="0" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitUpdate">确 定</el-button>
        <el-button @click="cancelUpdate">取 消</el-button>
      </div>
    </el-dialog>      

    <!-- 批量设置单价 -->
    <el-dialog title="批量设置单价" :visible.sync="priceOpen" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-form-item label="售电单价" prop="eqPrice">
          <el-input v-model="form.eqPrice" type="number" placeholder="请输入售电单价" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitPrice">确 定</el-button>
        <el-button @click="cancelPrice">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 更换设备 -->
    <el-dialog title="更换设备" :visible.sync="deviceOpen" width="800px" append-to-body>
      <el-row>
        <el-form ref="form" :model="form" :rules="rules" label-width="120px">
          <el-col :span="12">
            <el-form-item label="新设备编号" prop="meterNo">
              <el-input v-model="form.meterNo" placeholder="请输入新设备编号" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="总用电量" prop="totalEq">
              <el-input v-model="form.totalEq" readonly placeholder="请输入总用电量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="月结转累计电量" prop="monJzTotalEq">
              <el-input v-model="form.monJzTotalEq" readonly placeholder="请输入月结转累计电量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="月结转电量" prop="monJzEq">
              <el-input v-model="form.monJzEq" readonly placeholder="请输入月结转电量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="月结转电量" prop="monJzEq">
              <el-input v-model="form.monJzEq" readonly placeholder="请输入月结转电量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="免费电量" prop="freeEq">
              <el-input v-model="form.freeEq" readonly placeholder="请输入免费电量" />
            </el-form-item>
          </el-col> 
          <el-col :span="12"> 
            <el-form-item label="充值电量" prop="rechargeEq">
              <el-input v-model="form.rechargeEq" readonly placeholder="请输入充值电量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="已用电量" prop="useEq">
              <el-input v-model="form.useEq" readonly placeholder="请输入已用电量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="剩余电量" prop="remainEq">
              <el-input v-model="form.remainEq" readonly placeholder="请输入剩余电量" />
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitDevice">确 定</el-button>
        <el-button @click="cancelDevice">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listRoom,
  getRoom,
  delRoom,
  addRoom,
  updateRoom,
  batchPrice,
  deviceSet,
  getEgDetail,
  batchEdit
} from "@/api/base/room";
import RoomTree from "@/components/RoomTree";
import FusionSelect from "@/components/FusionSelect";
import RoomSelect from "@/components/RoomSelect";
import { listDevice } from "@/api/base/device";
export default {
  name: "Room",
  components: {
    RoomTree,
    FusionSelect,
    RoomSelect
  },
  data() {
    return {
      // 当前选中层级
      currentTree: {},
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示查询条件
      showSearch: true,
      // 总条数
      total: 0,
      // 房间档案表格数据
      roomList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 批量修改弹窗
      updateOpen: false,
      // 批量设置单价弹窗
      priceOpen: false,
      // 更换设备弹窗
      deviceOpen: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        // pId: null,
        // // floor: null,
        // roomNo: null,
        // linkMan: null,
        // tel: null,
        // orderNo: null,
        // enabled: null,
        // delFlag: null,
        // createPerson: null,
        // createDate: null,
        // updatePerson: null,
        // updateDate: null,
        // buySumQ: null,
        // cjqId: null,
        // meterNo: null,
        // meterProtoId: null,
        // loopCount: null,
        // alarmEq: null,
        // maxTzEq: null,
        // maxTjEq: null,
        // maxBuyEq: null,
        // freeEq: null,
        // jzType: null,
        // isJzFreeEq: null,
        // EqPrice: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        sId: [{ required: true, message: "学校不能为空", trigger: "blur" }],
        aId: [{ required: true, message: "校区不能为空", trigger: "blur" }],
        pId: [{ required: true, message: "楼座不能为空", trigger: "blur" }],
        floor: [
          { required: true, message: "所属楼层不能为空", trigger: "blur" }
        ],
        roomNo: [
          { required: true, message: "房间号码不能为空", trigger: "blur" }
        ],
        delFlag: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        buySumQ: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        eqPrice: [
          { required: true, message: "售电单价不能为空", trigger: "blur" }
        ],
        id: [
          { required: true, message: "新设备编号不能为空", trigger: "blur" }
        ],
        alarmEq: [
          { required: true, message: "报警电量不能为空", trigger: "blur" }
        ],
        maxTzEq: [
          { required: true, message: "最大透支不能为空", trigger: "blur" }
        ],
        maxTjEq: [
          { required: true, message: "最大围积不能为空", trigger: "blur" }
        ],
        maxBuyEq: [
          { required: true, message: "最大一次售电不能为空", trigger: "blur" }
        ],
        freeEq: [
          { required: true, message: "补助电量不能为空", trigger: "blur" }
        ],
        eqPrice: [
          { required: true, message: "售电单价不能为空", trigger: "blur" }
        ],
        meterNo: [
        { required: true, message: "设备编号不能为空", trigger: "blur" }
        ]
      },
      roomSelectParams: {},
      deviceOption: [],
      selection: [],
      getListParams: {},
    };
  },
  created() {
    this.getList();
    this.getDevice();
  },
  methods: {
    /** 查询房间档案列表 */
    getList() {
      this.loading = true;
      listRoom({...this.queryParams,...this.getListParams}).then(response => {
        this.roomList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    getDevice() {
      listDevice({ pageNum: 1, pageSize: 9999 }).then(response => {
        this.deviceOption = response.rows
      })
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    submitUpdate() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          const forms = this.ids.map(id => {
            return {
              ...this.form,
              id: id
            }
          })
          batchEdit(forms).then(response => {
            this.$modal.msgSuccess("修改成功");
            this.updateOpen = false
            this.getList()
          })
        }
      })
    },
    cancelUpdate() {
      this.updateOpen = false;
      this.reset();
    },
    submitPrice() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          batchPrice(this.form.eqPrice, this.ids).then(response => {
            this.$modal.msgSuccess("设置成功");
            this.priceOpen = false
            this.getList()
          })
        }
      })
    },
    cancelPrice() {
      this.priceOpen = false
      this.reset();
    },
    handleDevice() {
      getEgDetail(this.selection[0].id).then(response => {
        this.form = {
          ...response.data,
          ...this.selection[0]
        }
        this.deviceOpen = true
      })
    },
    submitDevice() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          deviceSet({ meterNo: this.form.meterNo, id: this.form.id }).then(response => {
            this.$modal.msgSuccess("设置成功");
            this.deviceOpen = false
            this.getList()
          })
        }
      })
    },
    cancelDevice() {
      this.deviceOpen = false
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        pId: null,
        floor: null,
        roomNo: null,
        linkMan: null,
        tel: null,
        orderNo: null,
        enabled: null,
        delFlag: null,
        createPerson: null,
        createDate: null,
        updatePerson: null,
        updateDate: null,
        remark: null,
        buySumQ: null,
        cjqId: null,
        meterNo: null,
        meterProtoId: null,
        loopCount: null,
        alarmEq: null,
        maxTzEq: null,
        maxTjEq: null,
        maxBuyEq: null,
        freeEq: null,
        jzType: null,
        isJzFreeEq: null,
        EqPrice: null,
        eqPrice: null
      };
      this.resetForm("form");
    },
    /** 查询按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.selection = selection
      this.ids = selection.map(item => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加房间档案";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getRoom(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改房间档案";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateRoom(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addRoom(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm("是否确认删除该房间档案的数据项？")
        .then(function() {
          return delRoom(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "base/room/export",
        {
          ...this.queryParams
        },
        `room_${new Date().getTime()}.xlsx`
      );
    },
    treeClick() {
      const nameMap = {
        build: "buildId",
        floor: "floor",
        room: "roomId"
      };
      this.roomSelectParams = {
        [nameMap[this.currentTree.name]]: this.currentTree.id
      };
      const nameMap2 = {
        build: "bId",
        floor: "floor",
        room: "id"
      };
      this.getListParams = {
        [nameMap2[this.currentTree.name]]: this.currentTree.id
          // this.currentTree.name == "floor"
          //   ? this.currentTree.data.name.substring(0, 1)
          //   : this.currentTree.id
      };
      this.handleQuery();
    }
  }
};
</script>

<style lang="scss" scoped>
.app-container {
  display: flex;
  overflow: hidden;
  .container_body {
    box-sizing: content-box;
    flex: 1;
    max-height: 100%;
    padding-left: 10px;
    overflow: auto;
    padding-right: 5px;
  }
}
</style>
